package com.cow.sram.module.distribution;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.cow.framework.core.base.BaseComponent;
import com.cow.sram.data.dao.OrgroleDAO;
import com.cow.sram.data.entity.Orgrole;
import com.cow.sram.data.entity.Roleinfo;
import com.cow.sram.data.mapper.RoleinfoMapper;

/**
 * 组织角色
 * @author Administrator
 *
 */
@Service
public class OrgRoleService extends BaseComponent{
	@Autowired
	OrgroleDAO orgRoleDao;
	@Autowired
	RoleinfoMapper roleinfoMapper;
	
	  /**用户角色查找*/
	 	public List<Roleinfo> findOrgrole(){
	 		//parmMap.put("userId", super.getCurUserId());
	 		return roleinfoMapper.queryOrgRoleinfo();
	 	}
	 	
	
	   /**判断组织是否有角色*/
	public boolean isExist(Integer orgId,Integer roleId){
		List<Orgrole> list=orgRoleDao.findByOrgidAndRoleid(orgId, roleId);
		if(list!=null && list.size()>0){
			return true;
		}else{
			return false;
		}
	}
	
	/**根据ID查询*/
	public Orgrole getOrgroleById(Integer id){
		return orgRoleDao.findOne(id);
	}
	
	/**新增*/
	public Orgrole newOrgrole(Orgrole orgrl){
		return orgRoleDao.save(orgrl);
	}
	
	/**删除*/
	public void delOrgrolrById(Integer id){
		 orgRoleDao.delete(id);
	}
	
}
